<?php

/**
 * Check
 * @param int $id parent_profile_updates ID
 * @param string $field column table 
 * @param string $value Value
 * @param bool $profile_request if false return blank object
 * @return object
 */
function req_check_if_updated($id, $field, $value, $profile_request = false){

	$CI=& get_instance();
	$CI->load->model('M_parent_profile_updates','m_ppu');
	$CI->load->model('M_parent_request_field','m_prf');
	$CI->load->model('M_profiles','m_p');

	$check = new stdClass;
	$check->changed = false;
	$check->new_value = "";
	$check->old_value = "";
	$check->status = false;
	$check->class = "";
	$check->checkbox = "";

	if($profile_request === false){ 
		return $check;
  }

	$req = $CI->m_ppu->pull($id,'id, profile_id, enrollment_id');

	if($req){

		$pro = $CI->m_p->pull($req->profile_id,$field);

		$get = array(
			'ppu_id' => $id,
			'col' => $field
			);
		$req_field = $CI->m_prf->pull($get);

		if($req_field){
			$check->changed = true;
			$check->new_value = $req_field->value;
			$check->old_value = $pro->$field;
			$check->status = $req_field->status;

			if($check->status == "APPROVE"){
				$check->class = "input_value_approve";
				$check->checkbox = "<span class=' icon-check'></span>";
			}elseif($check->status == "DENIED"){
				$check->class = "input_value_denied";
				$check->checkbox = "<span class=' icon-remove'></span>";
			}elseif($check->status == "PENDING"){
				$check->class = "input_value_pending";
				$check->checkbox = "<span class=' icon-tag'></span>";
			}else{}

		}else{
			$check->changed = false;
		}
	}

	return $check;
}